<script type="text/javascript">
    function openKCFinder_singleFile() {
        window.KCFinder = {};
        window.KCFinder.callBack = function(url) {
            window.KCFinder = null;
            // Actions with url parameter here
            $('#main_image').val(url.replace('<?php echo BASE_PATH?>', ''));
        };
        kfm_url = '<?php echo JS_PATH?>/kcfinder/browse.php';
        //window.open(kfm_url, 'kcfinder_single');
        window.open(kfm_url,"kfm","modal,width=960,height=640");
    }

    $(document).ready(function() {
        $('#getimage').click(function() {
            openKCFinder_singleFile();
        });
    });
</script>

<h1>
    <?php
        $category = $this->category;
        $catID = $category['category_id'];
        
        $allCategory = $this->allCategory;
        
        @$allParent = $allCategory[$catID]['all_parent'];
        $arrParent = explode(',', $allParent);
        $first = true;
        $cat_id = 0;
        foreach($arrParent as $parent_id):
            @$parent = $allCategory[$parent_id];
            if ($parent['left'] != 1) {
        ?>
            <a href="<?php echo BASE_URL?>/category/detail/?id=<?php echo $parent['category_id'];?>"><?php echo $parent['admin_title']?></a> &raquo;
        <?php
            }
        endforeach;

    ?>
    <span class="pink">
        <?php echo $category['admin_title']?>  
    </span>
    &raquo;
    Update Category
</h1>
<?php
if ($this->message) {
?>
<div class="alertmessage">
    <?php echo $this->message?>
</div>
<?php
} // if has message
?>
<div style="padding:5px"></div>
<form action="" method="post">
    <table width="70%" class="border">
        <thead>
            <tr>
                <td colspan="2">
                    Basic information
                </td>
            </tr>
        </thead>
        <tr>
            <td width="150">Category:*</td>
            <td><input type="text" name="admin_title" id="admin_title" class="input required" value="<?php echo htmlspecialchars(@$category['admin_title'])?>"></td>
        </tr>
        <?php
        if(@$category['level'] == 1) {
        ?>
        <tr>
            <td>Photo:</td>
            <td>
                <input type="text" name="main_image" id="main_image" class="input" value="<?php echo htmlspecialchars(@$category['main_image'])?>">
                <input type="button" id="getimage" value="Choose file">
            </td>
        </tr>
        <tr>
            <td>Photo link:</td>
            <td>
                <input type="text" name="photo_link" id="photo_link" class="input" value="<?php echo htmlspecialchars(@$category['photo_link'])?>">
            </td>
        </tr>
        <tr>
            <td>Embed Youtube</td>
            <td>
                <textarea name="embed_youtube" id="embed_youtube" class="textarea"><?php echo htmlspecialchars(@$category['embed_youtube'])?></textarea>
            </td>
        </tr>
        <tr>
            <td>Description</td>
            <td>
                <textarea name="description" id="description" class="textarea"><?php echo htmlspecialchars(@$category['description'])?></textarea>
            </td>
        </tr>
        <?php
        } // if level == 1
        ?>
        <tr>
            <td>Featured Category:</td>
            <td>
                <input type="checkbox" name="FeaturedCategory" id="FeaturedCategory"  <?php if(@$category['FeaturedCategory'] == 1) {echo "checked";}?> value="1">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="submit" name="submit">
                <input type="reset" value="Reset">
            </td>
        </tr>
    
    </table>
</form>

